/*
 * Copyright (c) 2020 hebeiyiliuba.com
 * All rights reserved.
 *
 */
package org.jeecg.modules.third.dongjiang.tax.system.constant.enums;

import com.google.common.collect.Maps;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 东疆税务系统
 *
 * @author duanlikao
 * @created 2021/3/11
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
public enum ServiceIdEnum {
    /**
     * 根据签名获取令牌 token
     */
    SERVICEID_TOKEN("getLpxx0001", "获取令牌token","verify-token"),
    /**
     * 新增/修改平台企业基本信息接口
     */
    SERVICEID_ENTERPRISES("postPtxx0001", "平台企业基本信息","verify-ptxx"),
    /**
     * 接收入驻平台企业的发布方信息数据
     */
    SERVICEID_PUBLISHER("postFbfxx0001", "发布方信息","verify-fbf"),
    /**
     * 接收入驻平台的服务方信息
     */
    SERVICEID_SERVICE_PROVIDE("postFwfxx0001", "服务方信息","verify-wccyfwf"),
    /**
     * 接收各企业订单信息 order
     */
    SERVICEID_ORDER("postDdxx0001", "订单信息","verify-wccydd"),
    /**
     *接收申报信息（增值税、印花税、附税）数据
     */
    SERVICEID_DECLARATION("postSbxx0001", "申报信息","verify-sbxx"),
    /**
     * 接收个人所得税详细信息数据
     */
    SERVICEID_PERSONAL_INCOME("postGrsdsxx0001", "个人所得税详细信息","verify-gsxx"),

    /**
     * 新增/修改个人所得税汇总信息接口
     * 接收个人所得税汇总信息数据
     */
    SERVICEID_PERSONAL_INCOME_DETAILED("postSdsxx0001", "个人所得税汇总信息","verify-gsxx"),
    /**
     * 销项发票信息
     * 平台给货主发票
     */
    SERVICEID_SALES_INVOICE ("postFpxx0005", "销项发票信息",""),


    /**
     * 临时纳税人登记信息接口
     */
    SERVICEID_TEMPORARY_TAXPAYER ("postLsNsrDjxx0001", "临时纳税人登记信息接口",""),

    ;

    private  String code;
    private  String msg;

    private  String verifypath;

    private static Map <String, ServiceIdEnum> codeMap = Maps.newHashMap();


    public String getCode() {
        return this.code;
    }

    public String getDesc() {
        return this.msg;
    }

    public String getVerifyPath() {
        return this.verifypath;
    }

    public static String getMsg(String code) {
        return codeMap.containsKey(code) ? codeMap.get(code).getDesc() : StringUtils.EMPTY;
    }

    public static boolean isValid(String code) {
        return codeMap.containsKey(code);
    }

    static {
        for (ServiceIdEnum status : ServiceIdEnum.values()) {
            codeMap.put(status.getCode(), status);
        }
    }

    public static ServiceIdEnum getServiceIdEnumByVal(String code) {
        return Arrays.stream(ServiceIdEnum.values()).collect(Collectors.toMap(
                ServiceIdEnum::getCode, value -> value, (k1, k2) -> k2)).get(code);
    }
}
